<?php
include_once 'cron.inc.php';
$infoid = 401;
$selfname = 'taskcron/other.php';
$sleep3 = 18000;
$nump = $pdo->query("select count(*) from zy_qqjob WHERE gnid=3 and cookiezt=0 and nexttime<={$time}")->rowCount();
$xz = ceil($nump / $size);
$shu = $pdo->query("SELECT * FROM zy_info WHERE sysid='{$infoid}' limit 1")->fetch();
$shu = $shu['times'];
$up_shu = $shu + 1;
if ($shu >= $xz) {
    $pdo->exec("update zy_info set times='1' where sysid='{$infoid}'");
    $shu = 0;
} else {
    $pdo->exec("update zy_info set times='" . $up_shu . "' where sysid='{$infoid}'");
}
$shu = $shu * $size;
$rs = $pdo->query("select * from zy_qqjob where gnid=3 and cookiezt=0 and nexttime<={$time} order by nexttime asc limit {$shu},{$size}");
while ($row = $rs->fetch()) {
    $id = $row['jobid'];
    if ($row['start'] == 0) {
        continue;
    }
    $url = qqtaskApi($row['type'], $row['qid']);
	
    $curl = curl_init();
    $urlarr = parse_url($url);
    if ($configs['local_cron'] == 1 && $urlarr['host'] == $_SERVER['HTTP_HOST']) {
        $url = str_replace('http://' . $_SERVER['HTTP_HOST'] . '/', 'http://127.0.0.1:80/', $url);
        $url = str_replace('https://' . $_SERVER['HTTP_HOST'] . '/', 'https://127.0.0.1:443/', $url);
        $url .= '&localcron=1';
        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Host: ' . $_SERVER['HTTP_HOST']));
    }
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($curl, CURLOPT_TIMEOUT, 1);
    curl_setopt($curl, CURLOPT_NOBODY, 1);
    curl_setopt($curl, CURLOPT_NOSIGNAL, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
    curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36');
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_exec($curl);
    curl_close($curl);
    $is_rate = array('wyqd');
	if (in_array($row['type'], $is_rate)) {
        $interval = $sleep3;
    }
    $nexttime = $time + $interval;
    $pdo->query("update `zy_qqjob` set `times`=`times`+1,`lasttime`='{$date2}',`nexttime`='{$nexttime}' where `jobid`='{$id}'");
}
$pdo->query("update `zy_info` set `last`='{$date}' where sysid='{$infoid}'");
$pdo->query("update `zy_info` set `times`=`times`+1,`last`='{$date}' where sysid='0'");
$pdo = null;
echo "<head><title>success in run</title></head>";
echo $date;